#ifndef JUNDEG_H
#define JUNDEG_H

#include "usart.h"
#include "main.h"

#define BSP_USART3_DMA_RX_BUF_LEN 500
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
  uint8_t  sof;
  uint16_t data_length;
  uint8_t  seq;
  uint8_t  crc8;
} Frame_Header_t;

/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t game_type : 4;
 uint8_t game_progress : 4;
 uint16_t stage_remain_time;
} ext_game_state_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t winner;
} ext_game_result_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint16_t robot_legion;
} ext_game_robot_survivors_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint32_t event_type;
} ext_event_data_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t supply_projectile_id;
 uint8_t supply_robot_id;
 uint8_t supply_projectile_step;
uint8_t supply_projectile_num;
} ext_supply_projectile_action_t;

/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
 uint8_t robot_id;
 uint8_t robot_level;
 uint16_t remain_HP;
 uint16_t max_HP;
 uint16_t shooter_heat0_cooling_rate;
 uint16_t shooter_heat0_cooling_limit;
 uint16_t shooter_heat1_cooling_rate;
 uint16_t shooter_heat1_cooling_limit;
 uint8_t mains_power_gimbal_output : 1;
 uint8_t mains_power_chassis_output : 1;
 uint8_t mains_power_shooter_output : 1;
} ext_game_robot_state_t;


typedef __packed struct
{
 uint16_t chassis_volt;
 uint16_t chassis_current;
 float chassis_power;
 uint16_t chassis_power_buffer;
 uint16_t shooter_heat0;
 uint16_t shooter_heat1;
} ext_power_heat_data_t;

typedef __packed struct{
 float x;
 float y;
 float z;
 float yaw;
} ext_game_robot_pos_t;
typedef __packed struct
{
 uint8_t power_rune_buff;
}ext_buff_musk_t;

typedef __packed struct
{
 uint8_t energy_point;
 uint8_t attack_time;
} aerial_robot_energy_t;
typedef __packed struct
{
 uint8_t armor_id : 4;
 uint8_t hurt_type : 4;
} ext_robot_hurt_t;
typedef __packed struct
{
 uint8_t bullet_type;
 uint8_t bullet_freq;
 float bullet_speed;
} ext_shoot_data_t;






typedef union
{
	uint8_t save[3];/* data */
	ext_game_state_t date;
}Jundge_Game_State;
typedef union
{
	uint8_t save[14];/* data */
	ext_power_heat_data_t date;
}Jundge_Power_Heat_Data_t;
typedef union
{
	uint8_t save[6];/* data */
	ext_shoot_data_t date;
}jundge_shoot_data_t;


extern uint8_t My_Queue[500];
extern QUEUE8_t Queue_Date;
extern Jundge_Power_Heat_Data_t jundge_power_heat_data_t ;
void Jundge_Analysis(void);

#endif



